from unittest import TestCase

from metadata.ingestion.source.database.column_type_parser import ColumnTypeParser

SQLTYPES = {
    "ARRAY",
    "BIGINT",
    "BIGNUMERIC",
    "BIGSERIAL",
    "BINARY",
    "BIT",
    "BLOB",
    "BOOL",
    "BOOLEAN",
    "BPCHAR",
    "BYTEINT",
    "BYTES",
    "CHAR",
    "CHARACTER VARYING",
    "CHARACTER",
    "CURSOR",
    "DATE",
    "DATETIME",
    "DATETIME2",
    "DATETIMEOFFSET",
    "DECIMAL",
    "DOUBLE PRECISION",
    "DOUBLE",
    "ENUM",
    "FLOAT",
    "FLOAT4",
    "FLOAT64",
    "FLOAT8",
    "GEOGRAPHY",
    "HYPERLOGLOG",
    "IMAGE",
    "INT",
    "INT2",
    "INT4",
    "INT64",
    "INT8",
    "INTEGER",
    "INTERVAL DAY TO SECOND",
    "INTERVAL YEAR TO MONTH",
    "INTERVAL",
    "JSON",
    "LONG RAW",
    "LONG VARCHAR",
    "LONG",
    "LONGBLOB",
    "MAP",
    "MEDIUMBLOB",
    "MEDIUMINT",
    "MEDIUMTEXT",
    "MONEY",
    "NCHAR",
    "NTEXT",
    "NUMBER",
    "NUMERIC",
    "NVARCHAR",
    "OBJECT",
    "RAW",
    "REAL",
    "ROWID",
    "ROWVERSION",
    "SET",
    "SMALLDATETIME",
    "SMALLINT",
    "SMALLMONEY",
    "SMALLSERIAL",
    "SQL_VARIANT",
    "STRING",
    "STRUCT",
    "TABLE",
    "TEXT",
    "TIME",
    "TIMESTAMP WITHOUT TIME ZONE",
    "TIMESTAMP",
    "TIMESTAMPTZ",
    "TIMETZ",
    "TINYINT",
    "UNION",
    "UROWID",
    "VARBINARY",
    "VARCHAR",
    "VARIANT",
    "XML",
    "XMLTYPE",
    "YEAR",
    "TIMESTAMP_NTZ",
    "TIMESTAMP_LTZ",
    "TIMESTAMP_TZ",
}


class DataTypeTest(TestCase):
    def test_check_datatype_support(self):
        for types in SQLTYPES:
            with self.subTest(line=types):
                col_type = ColumnTypeParser.get_column_type(types)
                col_type = True if col_type != "NULL" else False
                self.assertTrue(col_type, msg=types)
